from django.urls import path

from apps.users.views import UsernameCountView, MobileCountView, RegisterView, LoginView, LogoutView, CenterView, \
    EmailView, EmailVerifyView, CreateAddressView, AddressView, UpdateDestroyAddressView, DefaultAddressView, \
    UpdateTitleAddressView, ChangePasswordView, UserHistoryView

urlpatterns = [

    # django的类视图拥有自动查找指定方法的功能, 通过调用是通过as_view()方法实现

    # 1、直接使用方式
    # path('usernames/<username>/count/', UsernameCountView.as_view()),
    # 2、使用转换器,username_converter是转换器转换后的名字---在总路由汇总
    path('usernames/<username_converter:username>/count/', UsernameCountView.as_view()),
    path('mobile/<mobile_converter:mobile>/count', MobileCountView.as_view()),
    path('register/', RegisterView.as_view()),
    path('login/', LoginView.as_view()),
    path('logout/', LogoutView.as_view()),
    path('info/', CenterView.as_view()),
    path('emails/', EmailView.as_view()),
    path('emails/verification/', EmailVerifyView.as_view()),
    path('addresses/create/', CreateAddressView.as_view()),
    path('addresses/', AddressView.as_view()),
    path('addresses/<address_id>/', UpdateDestroyAddressView.as_view()),
    path('addresses/<address_id>/default/', DefaultAddressView.as_view()),
    path('addresses/<address_id>/title/', UpdateTitleAddressView.as_view()),
    path('password/', ChangePasswordView.as_view()),

    path('browse_histories/', UserHistoryView.as_view()),
]



